//
//  ZYCCycleFriendsDetailBottomView.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/19.
//

#import "ZYCCycleFriendsDetailBottomView.h"
#import "NSString+Size.h"

#define bottomH 75
@interface ZYCCycleFriendsDetailBottomView ()

@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UILabel *uploadNameLabel;
@property (nonatomic, assign) CGFloat height;
@end
@implementation ZYCCycleFriendsDetailBottomView

- (void)setContent:(NSString *)content{
    _content = content;
    _contentLabel.text = content;
    
    CGSize titleSize = [content sizeWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) constrainedToWidth:kScreenWidth];
    self.height = titleSize.height;
     self.frame = CGRectMake(0, kScreenHeight - kNavBarAndStatusBarHeight - bottomH - self.height, kScreenWidth, bottomH + self.height);
}

- (void)setUploadUserName:(NSString *)uploadUserName{
    _uploadUserName = uploadUserName;
    _uploadNameLabel.text = [NSString stringWithFormat:@"发布人:%@",uploadUserName];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.alpha = 0.7;
        self.height = 0.0f;
        self.frame = CGRectMake(0, kScreenHeight - kNavBarAndStatusBarHeight - bottomH - self.height, kScreenWidth, bottomH + self.height);
        self.backgroundColor = HEX_RGB(@"#000000");
        [self addSubview:self.contentLabel];
        [self addSubview:self.uploadNameLabel];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10.0f);
            make.right.equalTo(self).offset(-10.0f);
            make.top.equalTo(self).offset(11.0f);
        }];
        
        [self.uploadNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10.0f);
            make.right.equalTo(self).offset(-10.0f);
            make.height.mas_equalTo(74.0f);
            make.top.equalTo(self.contentLabel.mas_bottom).offset(0.0f);
        }];
    }
    return self;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"#FFFFFF") textAlignment:ZZTextAlignmentLeft];
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}

- (UILabel *)uploadNameLabel {
    if (!_uploadNameLabel) {
        _uploadNameLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"#E6E6E6") textAlignment:ZZTextAlignmentLeft];
    }
    return _uploadNameLabel;
}

- (void)show{
    [UIView animateWithDuration:0.7 animations:^{
        self.frame = CGRectMake(0, kScreenHeight - kNavBarAndStatusBarHeight - bottomH - self.height, kScreenWidth, bottomH + self.height);
    }completion:^(BOOL finished) {
        self.hidden = NO;

    }];
}
- (void)disMiss{
    [UIView animateWithDuration:0.7 animations:^{
        self.frame = CGRectMake(0, kScreenHeight - kNavBarAndStatusBarHeight, kScreenWidth, bottomH);
    }completion:^(BOOL finished) {
        self.hidden = YES;
    }];
}
@end
